<template>
    <div>
        <div>
            <mt-header title="贷款进度">
                <router-link to="/" slot="left">
                    <mt-button icon="back">返回</mt-button>
                </router-link>
                <mt-button icon="more" slot="right"></mt-button>
            </mt-header>
        </div>
        <van-pull-refresh v-model="isLoading" @refresh="onRefresh" style="height: 900px">
            <el-card style="border-radius: 16px; margin-top: 10px; width: 360px; margin-left: 6px" v-for="(item, index) in creditList" :key="index" class="box-card">
                <div slot="header" class="clearfix">
                    <van-button round  plain type="primary"> {{item.duringYear}} 年度</van-button>
                    <el-button style="float: right; padding: 3px 0" type="text" @click="$router.push('/count')">查看贷款指南</el-button>
                </div>
                <van-steps :active="item.isIssue === '已发放' ? 3 : item.isBankCheck === '已审批' ? 2 : item.countyCheckStatus === '已审批' ? 1 : item.creditStatus === '通过' ? 0 : 1">
                    <van-step><van-tag round  type="primary">乡审批</van-tag></van-step>
                    <van-step><van-tag round type="success">县审批</van-tag></van-step>
                    <van-step><van-tag round type="danger">银行审批</van-tag></van-step>
                    <van-step><van-tag round type="warning">贷款发放</van-tag></van-step>
                </van-steps>
            </el-card>

        </van-pull-refresh>
    </div>
</template>

<script>
    import Toast from "vant/lib/toast";
    import axios from "axios";

    export default {
        name: "Progress",
        data() {
            return{
                active: 0,
                isLoading: false,
                creditList: [],
            }
        },
        created() {
            this.InitCreditList()
        },
        methods: {
            InitCreditList() {
                axios.get('http://124.70.180.155:8080/system/user/profile',
                    {
                        headers: { Authorization: sessionStorage.getItem('token')}
                    }).then(res => {
                    this.user = res.data.data
                    axios.get('http://124.70.180.155:8080/student/credit/data/name/' + this.user.userName,
                        {
                            headers: { Authorization: sessionStorage.getItem('token')}
                        }).then(res => {
                        console.log(res.data.data)
                        this.creditList = res.data.data
                    })

                })

            },
            onRefresh() {
                setTimeout(() => {
                    Toast('刷新成功');
                    this.isLoading = false;
                    this.count++;
                }, 1000);
            },
        }
    }
</script>

<style scoped>

</style>
